# Common imports
import pandas as pd
# import numpy as np
import scipy.io as sio
# custom functions
import mvc
%load_ext autoreload
%autoreload 2
# Path
from pathlib import Path
PROJECT_PATH = Path('./')
DATA_PATH = PROJECT_PATH / 'data'
MODEL_PATH = PROJECT_PATH / 'model'
# Figures
OFFLINE = True
if OFFLINE:
import plotly.offline as py
py.init_notebook_mode(connected=True)
else:
import plotly.plotly as py
import dill as pickle
df_tidy = pd.read_feather(DATA_PATH / 'df_tidy')
df_tidy_normalized = pd.read_feather(DATA_PATH / 'df_tidy_normalized')
df_wide = pd.read_feather(DATA_PATH / 'df_wide')
with open(MODEL_PATH / 'conf.pkl', 'rb') as h:
conf = pickle.load(h)
muscle_by_dataset = mvc.plot.count_by_dataset(
df_tidy,
values='test',
index='dataset',
columns='muscle',
ylabel=conf['DATASETS'],
xlabel=conf['MUSCLES'],
title='Muscles by dataset')
py.iplot(muscle_by_dataset, filename='mvc/muscles_by_dataset')
muscle_by_dataset = mvc.plot.count_by_dataset(
df_tidy,
values='muscle',
index='dataset',
columns='test',
ylabel=conf['DATASETS'],
xtitle='Tests',
title='Tests by dataset')
py.iplot(muscle_by_dataset, filename='mvc/tests_by_dataset')
test_count_bar = mvc.plot.count_bar(
df_tidy, 'test', title='Tests count', xtitle='n', ytitle='Tests')
py.iplot(test_count_bar, filename='mvc/test_count_bar')
muscle_count_bar = mvc.plot.count_bar(
df_tidy, 'muscle', ylabel=conf['MUSCLES'], title='Muscles count', xtitle='n')
py.iplot(muscle_count_bar, filename='mvc/muscle_count_bar')
max_by_test = mvc.plot.max_by_test(
df_tidy_normalized,
ylabel=conf['MUSCLES'],
xtitle='Tests',
title='Which test normalizes which muscle (normalized)')
py.iplot(max_by_test, filename='mvc/max_by_test')
nan_count_bar = mvc.plot.count_nan(
df_wide.iloc[:, df_wide.columns != 'muscle'],
title='NaN count for each test',
xtitle='Tests',
ytitle='NaN count')
py.iplot(nan_count_bar, filename='mvc/nan_count_bar')
IMAGES_PATH = Path('./data/positions_mvc.mat')
positions = sio.loadmat(IMAGES_PATH)['positions']
positions_all = mvc.plot.mvc_positions(
positions, idx=conf['TESTS'], title='Illustrations of MVIC tests')
py.iplot(positions_all, filename='mvc/positions_all')